package io.gitee.heis.vehicle.race.sample03.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import io.gitee.heis.vehicle.race.sample03.Race03;

/**
 * 使用 Spring 容器來管理对象实例
 */
@Configuration
@ComponentScan({"io.gitee.heis.vehicle.race.sample03"})
public class VehicleTest03 {

  private static ApplicationContext applicationContext;

  public static void main(String[] args) {
    /**
     * 第3代使用注解来自动装配，只需要指定
     */
    applicationContext =
            new AnnotationConfigApplicationContext(VehicleTest03.class);//初始化容器
    Race03 race = applicationContext.getBean("race03", Race03.class);//自动准备赛道
    try {
      race.start();//开始测试
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
